/**
 * XHR Ajax request gesture
**/

var xhr = new XMLHttpRequest();

function _post(parameters) {
	var postString = '';
	
	for(var i in parameters.data) {
		postString += i+'='+parameters.data[i]+'&';
	}
	
	postString = postString.substring(0, postString.length-1);
	
	xhr.open('POST', parameters.url, false);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	try {
		xhr.send(postString);
	} catch (e) {
		log(e.message);
	}
	
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && xhr.status == 200) {
			parameters.callback(xhr.responseText);
		}
	};
}
